import { PopmenuGroupId } from "@/mdesign-lib/mdesign-app.umd.js";
import type { MetaclassType } from "@/mdesign-lib/mdesign-app.umd.js";
import type { StType } from "@/mdesign-lib/mdesign-app.umd.js";
import { ModelData } from "@/mdesign-lib/mdesign-app.umd.js";
import { MatrixNode, MatrixNodeData } from "@/mdesign-lib/mdesign-graph.umd.js";

export interface MenuItemPoolItem {
  label: string;
  value: string;
  icon?: string;
  index?: number;
  group?: number;
  disabledWhenReadonly?: boolean;
  children?: MenuItemPoolItem[];
  stIds?: string[];
  disabled?: boolean;
  itemFlowId?: string;
}

export interface RelationType {
  id: string; // 跟哪个模型有关联关系
  type: StType[]; // 有哪些关联关系
}
export interface RequirementOption {
  expand: boolean; // 是否展开
  shapeDepth: number; // 图形层级
  parentNodeId: string; // 上连接线的图形id
  relationTypes: RelationType[];
  // text:string // 需求内容
  modelTypeCnName: string; // 需求类型
  // id:string // 需求ID
}
export interface SideBarTypeName {
  classType: string;
  cnName: string;
  enName: string;
  nameSpace: string;
  stereotype: string;
  type: string;
  typeName: string;
}

export type SiderBarItemGroup = {
  id: string;

  // cnName:string
  enName?: string;
  name: string;
  children: SiderBarItem[];
  isActive?: boolean;
};

export type SiderBarItem = {
  modelId?: string; // 构造型id或元类id
  shapeKey?: string;
  operation?: string; // 特殊操作，对于纯图形的元素就是CREATE_SHAPE，其他类型的操作可以后续拓展
  operationParam?: any; // 特殊操作的参数
  dropdownTag?: string; // 下拉标签，用来处理下拉类型的组件菜单， 相同dropdownTag的item会被收起到一个下拉菜单里
  icon?: string;
  cnName?: string;
  showData: {
    icon: string;
    name: string;
    metaclass?: MetaclassType.Stereotype | MetaclassType.Class | string; // 构造型的metaclass， 如果是构造型就是stereotype， 否则是class
    siderBarkey?: string;
  };

  // "cnName": string,
  // "enName": string,
  // "icon": string,
  // // "key": string,

  // name:string
  children?: SiderBarItem[];
  modelLibId?: string;
  uid?: string;
  isActive?: boolean;
  payload?: { [key: string]: any };
  stIds?: string[];
  action?: string; // 指定执行哪个action
  treeModelId?: string; // 通过chooseMetaclass放到图上上，要重定向到树拖拽，这个id用来记录树节点的id
  packageStructureId?: string; // 包结构id，用于导航图创建目录选择的包结构，需要将该包结构下所有视图显示
  // modelId?: string // profile图中拖拽 metaclass用到
  // stIds?:string[]
  // group?:string
  // id?: string
  // shapeKey?: ShapeKey
  // metaclass?: MetaclassType
};

export type ModelInfoType = {
  enName: string;
  cnName: string;
  label: string;
  metaclass: string;
  value: string;
  icon: string;
  appliedStereotypes: Array<string>;
};
export type NumberManageModelData = ModelData & {
  /**
   * 前缀，前缀是记录在owner上的，当前元素如果前缀则取其最新的父级的前缀
   * 有numberOwner的元素才有前缀属性
   */
  prefix?: string;
  number?: string;
  numberPropertyKey?: string;
  hasChild?: boolean;
  disabled?: boolean;
};
export type MMatrixNodeData = ModelData & MatrixNodeData;
export type MMatrixNode = MatrixNode<MMatrixNodeData>;
// {
//   icon: string
//   id: string // 此id是需求前缀与序号的组合，模型树显示
//   instanceId: string // 模型id
//   name: string
//   text: string
//   model: ModelData // 模型数据
//   prefix: string // 给子节点显示的前缀
//   parentPrefix: string // 当前节点显示的前缀，即=父节点的prefix
//   number: string // 序号
//   metaclass: string
//   children?: RequirementSpType[],
//   baseSt?:StType,

// }

export type PopmenuItem = {
  modelId: string;
  operation?: string;
};
export type PopmenuGroup = {
  groupId: PopmenuGroupId;
  children: PopmenuItem[];
};
export type DiagramPopmenuGroup = {
  diagramIds: string[];
  groups: PopmenuGroup[];
};
export type PopMenuConfig = {
  defaultConfig: PopmenuGroup[];
  diagramConfig: DiagramPopmenuGroup[];
};
export type ContextMenuConfig = {
  createDiagram: string[];
};
export type MenuConfig = {
  popMenu: PopMenuConfig;
  contextMenu: ContextMenuConfig;
  propertyMenu: string[];
};

export type MenuConfigForView = {
  menuConfig: any;
  modelDatas: ModelData[];
};

export type ChangeData = {
  changeElementId: "";
  changePropertyKeys: string[];
  changeType: number;
};

export type SplitTermUnify = {
  modelId: string;
  originText: string;
};

export type TermResUnify = {
  modelId: string;
  terms: string[];
};
